package com.woniuxy.project115.kaer.tenant.controller;


import cn.hutool.core.bean.BeanUtil;
import com.alipay.api.domain.UserIdentity;
import com.woniuxy.project115.kaer.commons.util.JwtUtil;
import com.woniuxy.project115.kaer.commons.util.Result;
import com.woniuxy.project115.kaer.tenant.consumer.EvaluateOrderConsumer;
import com.woniuxy.project115.kaer.tenant.form.EvaluateOrderForm;
import com.woniuxy.project115.kaer.tenant.param.EvaluateOrderParam;
import com.woniuxy.project115.kaer.tenant.service.OrderEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HuH
 * @since 2025年02月18日
 */
@RestController
@RequestMapping("/orderEvaluate")
@Api(tags = "订单评价接口")
public class OrderEvaluateController {
    @Resource
    private OrderEvaluateService orderEvaluateService;

    @PostMapping("/evaluate")
    @ApiOperation("评价订单")
    public Result evaluate(@RequestBody EvaluateOrderForm form, @RequestHeader String token) throws Exception{
        Integer userId = JwtUtil.getUserId(token);
        String userName = JwtUtil.getUserName(token);
        orderEvaluateService.evaluate(BeanUtil.toBean(form, EvaluateOrderParam.class), userId, userName);
        return Result.succeed("评价成功");
    }
}
